package com.smalluz.ad.modules.oe.tools;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;

import org.apache.commons.lang3.StringUtils;

import com.smalluz.ad.modules.oe.result.advertiser.AdvertiserInfo;

/**
 * @author biteam
 * @Title: OeBizTool
 * @Description: TODO(描述)
 * @site http://www.smalluz.com/
 * @email 510711793@qq.com
 * @date 2022-06-13 22:16
 */
public class OeBizTool {

    /**
     * 获取账户名称
     * @param accounts
     * @return
     */
    public static List<String> getThirdAccountName(List<AdvertiserInfo> accounts) {
        Set<String> mcuns = new HashSet<>();
        for (int i = 0; i < accounts.size(); i++) {
            AdvertiserInfo item = accounts.get(i);
            if (StringUtils.isNotBlank(item.getAdvertiserName())) {
                mcuns.add(item.getAdvertiserName());
            }
        }
        return new ArrayList<String>(mcuns);
    }

    /**
     * 获取查询的纵横组账户
     * @param list
     * @param accountNumber
     * @return
     */
    public static AdvertiserInfo getByAccountNumber(List<AdvertiserInfo> list,String accountNumber){
        Optional<AdvertiserInfo> mpOptional = list.stream().filter(mc -> mc.getAdvertiserName().equals(accountNumber)).findFirst();
        return mpOptional.orElse(null);
    }

}
